package com.collect.senegal.zhiAdater.zhiChartLevelDay;

import android.view.View;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.collect.senegal.R;
import com.collect.senegal.zhiBean.zhiReceive.ZHIRLevelDayEntity;

public class ZHIChartLevelDayAdjuster extends BaseQuickAdapter<ZHIRLevelDayEntity, BaseViewHolder> {

    public ZHIChartLevelDayAdjuster() {
        super(R.layout.item_chart_level_day_list, null);
    }

    private OnZHIChartLevelDayAdjusterItemClickListener mOnZHIChartLevelDayAdjusterItemClickListener;

    @Override
    protected void convert(BaseViewHolder helper, ZHIRLevelDayEntity item) {
        RelativeLayout content_bg = helper.getView(R.id.rl_content_bg);
        View view_bar = helper.getView(R.id.view_bar);

        content_bg.setBackgroundColor(item.isChecked() ? mContext.getResources().getColor(R.color.theme_black_4) : mContext.getResources().getColor(R.color.white));
        content_bg.setBackgroundResource(item.isChecked() ? R.drawable.bg_solid_radius_theme_green0_10dp : R.drawable.bg_solid_radius_theme_color1_10dp);

        view_bar.setOnClickListener(v -> {
            mOnZHIChartLevelDayAdjusterItemClickListener.OnItemClick(item);
        });

        content_bg.setOnClickListener(v -> {
            mOnZHIChartLevelDayAdjusterItemClickListener.OnItemClick(item);
        });

        RelativeLayout.LayoutParams barLayoutParams =(RelativeLayout.LayoutParams) view_bar.getLayoutParams();
        barLayoutParams.width = item.getItemWidth();
        view_bar.setLayoutParams(barLayoutParams);
    }

    public void setOnZHIChartLevelDayAdjusterItemClickListener(OnZHIChartLevelDayAdjusterItemClickListener listener) {
        this.mOnZHIChartLevelDayAdjusterItemClickListener = listener;
    }

    public interface OnZHIChartLevelDayAdjusterItemClickListener {
        void OnItemClick(ZHIRLevelDayEntity zhirLevelDayEntity);
    }
}
